﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using BusinessObjects.BO_GetObjects;

public partial class Controls_ucGreenTab : System.Web.UI.UserControl
{
    string module_id;

    public string Module_id
    {
        get { return module_id; }
        set { module_id = value; }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            loadData();
        }
    }

    protected void loadData()
    {
        DataTable objDT = null;
        try
        {
            objDT = BO_Products.SelectByModule(1, 1, 12, Convert.ToInt32(module_id));
            rptProducts.DataSource = objDT;
            rptProducts.DataBind();
        }
        catch (Exception)
        {

            throw;
        }
        try
        {
            objDT = BO_Autions.SelectByModule(1, 1, 12, Convert.ToInt32(module_id));
            rptAution.DataSource = objDT;
            rptAution.DataBind();
            rptInvest.DataSource = objDT;
            rptInvest.DataBind();
        }
        catch (Exception)
        {

            throw;
        }
    }

    protected string getAutionDiv(int index)
    {
        if (index % 2 != 0)
        {
            return "aution_odd";
        }
        else
            return " aution_even";
    }

    protected string getEvent(int index)
    {
        if (index % 2 != 0)
        {
            return "";
        }
        else
        {
            return "even";
        }
    }

    protected string getPrice(string unit_price)
    {
        decimal price = Convert.ToDecimal(unit_price);
        string strPrice = price.ToString();
        if (price > 1000000)
        {
            int dTemp = 0;
            dTemp += Convert.ToInt32(price / 1000000);
            strPrice = dTemp + " Triệu ";
            if (price - Convert.ToDecimal(dTemp * 1000000) > 0)
            {
                strPrice += (price - Convert.ToDecimal(dTemp * 1000000)) / 1000;
            }
        }
        return strPrice;
    }

}